package forms;

import java.io.Serializable;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.upload.FormFile;


public class Degree extends ActionForm implements Serializable{
	// all the information related to each degree
	String location;
	String university;
	String major;
	String GPA;
	String degreeTitle;
	String month;
	String year;
	String otherMajor;
	
	// SETTER METHODS
	public void setLocation (String somePlace)  {
		this.location = somePlace;
	}
	
	public void setUniversity (String someSchool)  {
		this.university = someSchool;
	}
	
	public void setMajor (String someMajor)  {
		this.major  = someMajor;
	}

	public void setOtherMajor(String otherMajor) {
		this.otherMajor = otherMajor;
	}
	
	public void setGPA (String someGPA)  {
		this.GPA = someGPA;
	}
	
	public void setDegreeTitle (String someDegreeTitle)  {
		this.degreeTitle = someDegreeTitle;
	}
	
	public void setMonth (String someMonth)  {
		this.month = someMonth;
	}
	
	public void setYear (String someYear)  {
		this.year = someYear;
	}
	
	
	// GETTER METHODS
	public String getLocation ()  {
		return this.location;
	}
	
	public String getUniversity ()  {
		return this.university;
	}
	
	public String getMajor ()  {
		return this.major;
	}
	
	public String getOtherMajor() {
		return otherMajor;
	}
	
	public String getGPA ()  {
		return this.GPA;
	}
	
	public String getDegreeTitle ()  {
		return this.degreeTitle;
	}
	
	public String getMonth ()  {
		return this.month;
	}
	
	public String getYear ()  {
		return this.year;
	}
	
	
	
	private FormFile myFile;
	private String firstName;
	private byte fileData;
	
	public void setMyFile(FormFile myFile) {
		this.myFile = myFile;
	}
	
	public FormFile getMyFile ()  {
		return myFile;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	
	public byte getFileData() {
		return fileData;
	}

	public void setFileData(byte fileData) {
		this.fileData = fileData;
	}
	
	
	
	
	
	
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {

		ActionErrors errors = new ActionErrors();
	
		if ((GPA == null) || (GPA.length() < 1))
				errors.add("firstMsgTag1", new ActionMessage("errors.required",
						"GPA"));
		else
			try{
				Integer.parseInt(GPA);
			}catch (NumberFormatException ex){
				errors.add("gpaMsgTag1", new ActionMessage("errors.notanumber", "GPA"));
			}
	
		if ((month == null) || (month.length() < 1))
				errors.add("lastMsgTag1", new ActionMessage("errors.required",
						"Month"));
		
		
		return errors;
	}
	
	
	
	
	
}
